package com.wzcl.app.config.oauth.controller;

import com.wzcl.app.model.common.CodeMsg;
import com.wzcl.app.model.common.RVO;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class LogoutController {

    @Resource
    private ConsumerTokenServices consumerTokenServices;

    @GetMapping("/userLogout")
    public RVO<String> logout(@RequestParam("token") String accessToken) {
        if (consumerTokenServices.revokeToken(accessToken)) {
            return RVO.success();
        }
        return RVO.error(CodeMsg.SYSTEM_ERR);
    }
}